package com.gxa.order.controller;

import com.gxa.order.param.ArtOrderParam;
import com.gxa.order.param.IdParam;
import com.gxa.order.param.MacOrderParam;
import com.gxa.order.service.ArtOrderService;
import com.gxa.order.service.CheckService;
import com.gxa.order.service.MacOrderService;
import dto.ResultDTO;
import entity.ArtOrder;
import entity.Member;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import util.Response;

@RestController
@RequestMapping("order01")
@Api(tags = "订单模块01")
public class OrderController01 {
    @Autowired
    private MacOrderService macOrderService;
    @Autowired
    private ArtOrderService artOrderService;
    @Autowired
    private CheckService checkService;


    @GetMapping("test02")
    @ApiOperation(value = "测试mq接口")
    @ApiImplicitParam(name = "macOrderId" , value = "id" , required = true)
    public ResultDTO test02(Integer macOrderId){
        return checkService.addMac(macOrderId);
    }
    @GetMapping("test01")
    @ApiOperation(value = "测试接口")
    @ApiImplicitParam(name = "name" , value = "姓名" , required = true)
    public ResultDTO test01(String name){
        return Response.success("sadjahuo");
    }

    @ApiOperation(value = "根据申请人id，机票id 查询声请人信息，机票信息返回")
    @PostMapping("find/userAndFlight")
    public ResultDTO findUserAndFlight(@RequestBody IdParam idParam){
        return macOrderService.findUserAndFlight(idParam.getMemberId(),idParam.getFlightIds());
    }

    @ApiOperation(value = "增加正常订单的接口")
    @PostMapping("add/macOrder")
    public ResultDTO addMacOrder(@RequestBody MacOrderParam param){
        return macOrderService.addMacOrder(param);
    }

    @ApiOperation(value = "根据申请人id 查询声请人信息")
    @PostMapping("find/apply")
    public ResultDTO findApply(@RequestBody Member member){
        System.out.println("111111");
        return artOrderService.findUser(member.getMemberId());
    }

    @ApiOperation(value = "增加人工订单的接口")
    @PostMapping("add/artOrder")
    public ResultDTO addArtOrder(MultipartFile file, ArtOrderParam artOrderParam){
        return artOrderService.addArtOrder(file,artOrderParam);
    }
}
